//
//  SQL__Tests.m
//  SQL演练Tests
//
//  Created by Guo Rui on 2017/10/25.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "NSString+SQLChain.h"
#import "SQLChain.h"
#import "SQLHandler.h"
@interface SQL__Tests : XCTestCase
@property (strong, nonatomic) SQLChain *chain;
@end

@implementation SQL__Tests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    self.chain = [[SQLChain alloc] init];
    [SQLHandler.sharedInstance databaseWithName:@"xixi"];
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
    
    NSLog(@"%@", @"name".integer);
    
    // @"(id INTEGER PRIMARY KEY AUTOINCREMENT, name text NOT NULL)"
    
//self.chain.
//    createTable(@"t_student").
//    fieldsDefine(@"(".
//                 append(@"id".integer.primary_key.autoincrement).
//                 dot.
//                 append(@"name".text.notnull).
//                 append(@")")).
//    end().
//    output();
    
//    self.chain.
//    createTable(@"t_student").
//    fieldsDefine(
//                 @"id".integer.primary_key.autoincrement.
//                 dot.
//                 append(@"name").text.notnull
//                 ).
//    end().
//    output();

    
    NSLog(@"%@", @"name".eq(str(jack)));
    NSLog(@"%@", @"name".neq(str(jack)));
    NSLog(@"%@", @"name".greater(str(jack)));
    NSLog(@"%@", @"name".greaterEq(str(jack)));
    NSLog(@"%@", @"name".less(str(jack)));
    NSLog(@"%@", @"name".lessEq(str(jack)));
    NSLog(@"%@", @"name".like(str(jack)));
    NSLog(@"%@", str(name).eq(str(jack)).AND(str(score)).greater(num(12)));
    
    
    //   self.chain.createTable(@"t_student").fieldsDefine(@"(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, class_id INTEGER, CONSTRAINT fk_student_id_class_id FOREIGN KEY (class_id) REFERENCES t_class(id))").end().output();
    NSLog(@"%@", @"id".integer.primary_key.autoincrement.
          dot(@"name").text.notnull.
          dot(@"class_id").integer.
          dot(foreign_key(@"fk_student_id_class_id", @"class_id", @"t_class", @"id")));
    
}

- (void)testConnect
{
    // like
    NSLog(@"%@", @"".like(@"aa"));
    
    // 
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
        
        
        
    }];
}

@end
